var ptCollectionsAttr = {
	change:false,
	remove:function(id,_this){
		ptCollectionsAttr.change = true;
		$.get("/api/collections/removeAttr?pid="+id,function(res){
				
			if(res.error){
				showStickyErrorToast(res.message);
			}else{
				
			}
			
		}).error(function(data, status, headers, config) {
			if(status=="error") showStickyErrorToast(data.responseText);
			console.log(data);
			console.log(status);
			
			
		});
		$(_this).parent().parent().remove();
		
	},
	rows:function(r){
		var y = r;
		var html='<tr class="layout_row">'; 
		html+='<td width="30%">'+y.attr+'</td>';
			
		html+='<td>'+y.created+'</td>';
		html+='<td><a href="javascript:void(0)" class="cblack font11"  onclick=ptCollectionsAttr.remove("'+y.id+'",this)><i class="fa fa-trash-o"></i></a></td>';
			
			
		html+='</tr>';
		return html;
	}
	
	
};

$(".add-collection-attr").live('click',function(e){
	var ipcollection = $(this).parent().find('input');
	if(ipcollection.val() == ""){
		ipcollection.focus().select();
		return false;
	}else{
		ptCollections.actions.saveAttr(ipcollection.val());
		ipcollection.val('');
	}
});